<?php

function mreadFile($path = NULL) {
    $data = array();
    //
    $file = fopen($path, "r") or exit("Unable to open file!");
//Output a line of the file until the end is reached
    while (!feof($file)) {
        $data[] = fgets($file);
    }
    fclose($file);
    //
    return $data;
}
function mwriteFile($contents = array()) {
    $path = realpath("../ptnhuan-web1/data/films.txt");
    $file = fopen($path, "w") or exit("Unable to open file");
    foreach ($contents as $content) {
        if(!empty($content))
            $a = implode (";", $content);
        else
            $a = "";
        fwrite($file, $a.PHP_EOL);
    }
    fclose($file); 
}